package com.starpl.mobile.android.monthunsae.november.activity;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.LinearLayout;

import com.starpl.mobile.android.monthunsae.november.R;
import com.starpl.mobile.android.monthunsae.november.domain.UserInfo;
import com.starpl.mobile.android.monthunsae.november.handler.MessageListHandler;
import com.starpl.mobile.android.platform.common.base.BaseActivity;
import com.starpl.mobile.android.platform.common.base.BaseApplication;
import com.starpl.mobile.android.platform.component.StarplListView;


/**
 * 유저가 받은 쪽지를 보여주는 Activity
 * 
 * @author 우연화
 * @since 2011.03.10
 */
public class MessageActivity extends BaseActivity implements OnClickListener
{
	
	private MessageListHandler mMessageListHandler;
	private LinearLayout mLlList;
	
	private ImageButton mIbRefresh;
	
	/* (non-Javadoc)
	 * @see com.starpl.platform.common.base.BaseActivity#onCreate(android.os.Bundle)
	 */
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.message_activity);
		
		mIbRefresh = (ImageButton)findViewById(R.id.message_activity_ib_refresh);
		mLlList = (LinearLayout)findViewById(R.id.message_activity_ll_list);
		
		mIbRefresh.setOnClickListener(this);

		UserInfo userInfo = (UserInfo)BaseApplication.getGlobalPersistent("userInfo");
		
		mMessageListHandler = new MessageListHandler(this, userInfo.getUserId(), userInfo.getNickName());
		StarplListView listView = new StarplListView(mMessageListHandler);
		mLlList.addView(listView);
	}

	/* (non-Javadoc)
	 * @see android.view.View.OnClickListener#onClick(android.view.View)
	 */
	@Override
	public void onClick(View v)
	{
		switch(v.getId())
		{
		
		// 새로고침 버튼 클릭
		case R.id.message_activity_ib_refresh:
			mMessageListHandler.refresh();
			break;
			
		}
	}

}
